package com.tepth.remote.control.base.map.overlay;

import android.content.Context;

import com.baidu.mapapi.map.BitmapDescriptor;
import com.baidu.mapapi.map.BitmapDescriptorFactory;
import com.baidu.mapapi.map.MarkerOptions;
import com.baidu.mapapi.model.LatLng;

/**
 * Description:
 *
 * @author Hequn.Lee
 * @date 2018/11/14
 */
public class MarkerOverlay {

    /**
     * 传入坐标和图片路径创建覆盖物
     *
     * @param latlng 坐标点
     * @param icon   图片路径
     * @return 覆盖物对象
     */
    public static MarkerOptions builder(LatLng latlng, int icon) {
        return new MarkerOptions().position(latlng).icon(BitmapDescriptorFactory.fromResource(icon));
    }

    /**
     * 传入坐标和图片创建覆盖物
     *
     * @param latlng 坐标点
     * @param bitmap 图片
     * @return 覆盖物对象
     */
    public static MarkerOptions builder(LatLng latlng, BitmapDescriptor bitmap) {
        return new MarkerOptions().position(latlng).icon(bitmap);
    }

    /**
     * 传入坐标、图片和标题创建覆盖物
     *
     * @param latlng 坐标点
     * @param bitmap 图片
     * @param title  覆盖物标题
     * @return 覆盖物对象
     */
    public static MarkerOptions builder(LatLng latlng, BitmapDescriptor bitmap, String title) {
        return new MarkerOptions().position(latlng).icon(bitmap).title(title);
    }

    /**
     * 根据状态从ICON路径创建覆盖物
     *
     * @param latlng 坐标点
     * @param status 状态
     * @param title  覆盖物标题
     * @return 覆盖物
     */
    public static MarkerOptions builderByStatusFromResource(LatLng latlng, int status, String title) {
        BitmapDescriptor bitmapDescriptor;
        switch (status) {
            case 0:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorGreenFromResource();
                break;
            case 1:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorRedFromResource();
                break;
            case 2:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorYellowFromResource();
                break;
            case 3:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorGrayFromResource();
                break;
            default:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorPurpleFromResource();
                break;
        }
        return builder(latlng, bitmapDescriptor, title);
    }

    public static MarkerOptions builderByStatusFromLayout(LatLng latlng, int status, Context context, String title) {
        BitmapDescriptor bitmapDescriptor;
        switch (status) {
            case 0:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorGreenFromLayout(context, title);
                break;
            case 1:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorRedFromLayout(context, title);
                break;
            case 2:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorYellowFromLayout(context, title);
                break;
            case 3:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorGrayFromLayout(context, title);
                break;
            default:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorPurpleFromLayout(context, title);
                break;
        }
        return builder(latlng, bitmapDescriptor);
    }

    public static MarkerOptions builderPointByTypeFromBitmap(LatLng latlng, int type) {
        BitmapDescriptor bitmapDescriptor = null;
        switch (type) {
            case 0:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorBluePointFromResource();
                break;
            case 1:
                bitmapDescriptor = BitmapDescriptorBuilder.getBitmapDescriptorGreenPointFromResource();
                break;
            default:
                break;
        }
        return builder(latlng, bitmapDescriptor);
    }
}
